package com.example.hello.Scheduler;

import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;


@Service
@EnableScheduling          //开启基于注解方式的定时任务支持
public class ScheduleService {

    //@Scheduled(fixedDelay = 3000,initialDelay = 1000)
    public void showTime(){
        Date date=new Date();
        try {
            Thread.sleep(4000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String time = sdf.format(date);
        System.out.println(time);
    }
}
